/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2emu.gameserver.handler.voicedcommandhandlers;


import com.l2emu.gameserver.handler.IVoicedCommandHandler;
import com.l2emu.gameserver.model.actor.instance.L2PcInstance;
import com.l2emu.gameserver.model.entity.events.EventVoteVariable;

/**
 *
 * @author Rizel
 */
public class EventVote implements IVoicedCommandHandler
{
	private static final String[] VOICED_COMMANDS = {"vote_tvt", "vote_ctf"};
	
	/**
	 * 
	 * @see com.l2emu.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2emu.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
	 */
	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
	{
		EventVoteVariable e = new EventVoteVariable();
		if(command.startsWith("vote_tvt"))
	    {
				
				if (activeChar._voteEvent == false)
				{
					e.increaseVoteCount("tvt");
					activeChar._voteEvent = true;
					activeChar.sendMessage("You succesfully voted for the TvT event. TvT: " + e.getVoteCount("tvt") + " CTF: " + e.getVoteCount("ctf") + ".");
				}
				else
				{
					activeChar.sendMessage("You have already voted for an event.");	
				}
				return true;
				
	    }
		
		
		if(command.startsWith("vote_ctf"))
	    {
				if (activeChar._voteEvent == false)
				{
					e.increaseVoteCount("ctf");
					activeChar._voteEvent = true;
					activeChar.sendMessage("You succesfully voted for the CTF event. TvT: " + e.getVoteCount("tvt") + " CTF: " + e.getVoteCount("ctf") + ".");
				}
				
				else
				{
					activeChar.sendMessage("You have already voted for an event.");	
				}
				return true;
	    }
				
				

		return false;
		}
		
		
	/**
	 * 
	 * @see com.l2emu.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
	 */
	public String[] getVoicedCommandList()
	{
		return VOICED_COMMANDS;
	}
}
